extends NodeState

@export var enemy: BasicEnemy

var time: float
var is_shooting: bool


func _on_process(delta : float) -> void:
	process_shoot(delta)



func _on_enter() -> void:
	time = 0.0
	is_shooting = false
	enemy.animationPlayer.play(BasicEnemy.ANIMATION_IDLE)



func process_shoot(delta : float):
	time += delta
	if not is_shooting and time > enemy.duration_pre_shoot:
		is_shooting = true
		enemy.animationPlayer.play(BasicEnemy.ANIMATION_SHOOT)
		enemy.shoot_gun()



func on_shoot_animation_finished():
	transition_state(BasicEnemy.STATE_IDLE)
